package yxy.game.pm2.bean.timeline;

import org.quartz.Job;
import org.quartz.JobExecutionContext;
import yxy.apple.logger.Logger;

abstract public class JobHandle implements Job {
	private static final Logger logger = Logger.create(JobHandle.class);

	public static final int JOB_TYPE_PERIOD = 1;
	public static final int JOB_TYPE_CROND = 2;

	// 1:period 定时间隔（如5分钟一次  ），2:crond 方式（如："0 0 12 * * ?"  ）
	abstract public int jobType();

	abstract public String crond();

	abstract public long period();

	abstract public void init();

	abstract public void tick();

			
	@Override
	public void execute(JobExecutionContext jobExecutionContext) {
		long start = System.currentTimeMillis();
		tick();
		long time = System.currentTimeMillis() - start;
		if (time > 100) {
			logger.info("\ttick:\t耗时%s:\t%s", time, this.getClass().getSimpleName());
		}
	}
}